<template>
  <div class="statistics-box">
    <div class="renew-time" v-if="activeName == '1'">更新倒计时：{{ time }}s</div>
    <div class="box-left">
      <div class="item-box" style="flex: 1;">
        <div class="statistics-tips">
          <!-- <span class="title">待办列表</span> -->
          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="待办" name="1"></el-tab-pane>
            <el-tab-pane label="已办" name="2"></el-tab-pane>
          </el-tabs>
        </div>
        <div style="height: calc(100% - 52px);">
          <el-table :data="tableData" v-loading="tableLoading" height="100%"
            :header-cell-style="{ background: '#FAFBFC', color: '#828A9D', textAlign: 'center' }"
            :cell-style="{ textAlign: 'center', color: '#1B2431' }">
            <div slot="empty">
              <el-empty v-if="!tableLoading" image="https://img01.yzcdn.cn/vant/empty-image-default.png"></el-empty>
            </div>
            <el-table-column min-width="180px" prop="project_number" label="项目编号" show-overflow-tooltip>
              <template slot-scope="scope">
                <el-button type="text" @click="handleEdit(scope.row)">{{ scope.row.project_number }}</el-button>
              </template>
            </el-table-column>
            <el-table-column min-width="180px" prop="project_name" label="项目名称" show-overflow-tooltip></el-table-column>
            <el-table-column min-width="180px" prop="customer_name" label="客户名称"
              show-overflow-tooltip></el-table-column>
            <el-table-column min-width="180px" prop="type" label="类型" show-overflow-tooltip v-if="activeName == '1'">
              <template slot-scope="scope">
                <span v-if="scope.row.type == 1">项目</span>
                <span v-if="scope.row.type == 2">增减项</span>
                <span v-if="scope.row.type == 3">售后</span>
                <span v-if="scope.row.type == 4">优惠审批</span>
                <span v-if="scope.row.type == 5">施工</span>
                <span v-if="scope.row.type == 6">收款单</span>
                <span v-if="scope.row.type == 7">付款单</span>
                <span v-if="scope.row.type == 8">整改单</span>
              </template>
            </el-table-column>
            <el-table-column min-width="180px" prop="status" label="进度" show-overflow-tooltip v-if="activeName == '1'">
              <template slot-scope="scope">
                <!-- 项目 -->
                <div class="flex ac jc" v-if="scope.row.type == 1">
                  <p v-if="scope.row.object_status == 10">待启动</p>
                  <p v-if="scope.row.object_status == 15">待勘场</p>
                  <p v-if="scope.row.object_status == 18">待勘场出图</p>
                  <p v-if="scope.row.object_status == 20">出图中</p>
                  <p v-if="scope.row.object_status == 25">待报价</p>
                  <p v-if="scope.row.object_status == 30">洽谈中</p>
                  <p v-if="scope.row.object_status == 40 || scope.row.object_status > 40">已签约</p>
                  <p v-if="scope.row.object_status == 42">-待进场</p>
                  <p v-if="scope.row.object_status == 45">-施工中</p>
                  <p v-if="scope.row.object_status == 50">-已完工</p>
                  <p v-if="scope.row.object_status == 55">-待结算</p>
                  <p v-if="scope.row.object_status == 60">-款项付清</p>
                </div>
                <!-- 增减项 -->
                <div class="flex ac jc" v-if="scope.row.type == 2">
                  <p v-if="scope.row.object_status == 10">等待报价</p>
                  <p v-if="scope.row.object_status == 20">等待审核</p>
                  <p v-if="scope.row.object_status == 30">等待二审</p>
                  <p v-if="scope.row.object_status == 40">等待三审</p>
                  <p v-if="scope.row.object_status == 50">已支付,待确认</p>
                  <p v-if="scope.row.object_status == 60">已完成</p>
                </div>
                <!-- 售后 -->
                <div class="flex ac jc" v-if="scope.row.type == 3">
                  <p v-if="scope.row.object_status == 10">待派单</p>
                  <p v-if="scope.row.object_status == 20">待分配</p>
                  <p v-if="scope.row.object_status == 30">待现场确认</p>
                  <p v-if="scope.row.object_status == 40">待总部确认</p>
                  <p v-if="scope.row.object_status == 50">售后施工中</p>
                  <p v-if="scope.row.object_status == 60">售后完成</p>
                </div>
                <!-- 优惠 -->
                <div class="flex ac jc" v-if="scope.row.type == 4">
                  <p v-if="scope.row.object_status == 10">待客户总监审核</p>
                  <p v-if="scope.row.object_status == 20">待总经理审核</p>
                </div>
                <!-- 施工 -->
                <div class="flex ac jc" v-if="scope.row.type == 5">
                  <p v-if="scope.row.object_status == 30">待进场</p>
                  <p v-if="scope.row.object_status == 35">待分配工程经理</p>
                  <p v-if="scope.row.object_status == 40">待开工</p>
                  <p v-if="scope.row.object_status == 42">待开工</p>
                  <p v-if="scope.row.object_status == 45">施工中</p>
                  <p v-if="scope.row.object_status == 50">已完工</p>
                  <p v-if="scope.row.object_status == 60">质保中</p>
                  <p v-if="scope.row.object_status == 70">质保到期</p>
                </div>
                <!-- 收款单 -->
                <div class="flex ac jc" v-if="scope.row.type == 6">
                  <p v-if="scope.row.object_status == 1">提交勘场费用信息</p>
                  <p v-if="scope.row.object_status == 2">提交预付款信息</p>
                  <p v-if="scope.row.object_status == 3">提交进度款信息</p>
                  <p v-if="scope.row.object_status == 4">提交尾款信息</p>
                  <p v-if="scope.row.object_status == 5">提交增项款信息</p>
                  <p v-if="scope.row.object_status == 6">提交定金信息</p>
                </div>
                <!-- 付款单 -->
                <div class="flex ac jc" v-if="scope.row.type == 7">
                  <p v-if="scope.row.status == 1">提交工程款信息</p>
                  <p v-if="scope.row.status == 2">提交供应商货款信息</p>
                  <p v-if="scope.row.status == 3">提交装修退款信息</p>
                </div>
                <!-- 整改单 -->
                <div class="flex ac jc" v-if="scope.row.type == 8">
                  <p v-if="scope.row.object_status == 3000">待交整改</p>
                  <p v-if="scope.row.object_status == 3002">未通过</p>
                  <p v-if="scope.row.object_status == 3005">待审核</p>
                  <p v-if="scope.row.object_status == 3010">流程结束</p>
                </div>
              </template>
            </el-table-column>
            <el-table-column min-width="180px" :label="activeName == '1' ? '进度描述' : '操作描述'" show-overflow-tooltip>
              <template slot-scope="scope">
                <span>{{ scope.row.type == 1 || scope.row.type == 5 ? scope.row.current_node : speedDesc(scope.row.type,
                  scope.row) }}</span>
              </template>
            </el-table-column>
          </el-table>
        </div>

      </div>
    </div>

    <!-- <div class="box-right">
      <div class="item-box">
        <img class="info-bg" :src="require('@/assets/icon/index-bg.png')">
        <div class="flex">
          <div class="user-header">
            <img class="user-img" :src="userInfo.avatar">
          </div>
          <div class="user-info">
            <div class="flex" style="align-items: end;">
              <div class="user-name">{{ userInfo.nickName }}</div>
              <div class="user-desc" style="margin-left: 10px;">{{ userInfo.position }}</div>
            </div>
            <div class="user-desc">{{ userInfo.cityName }}</div>
            <div class="user-desc">{{ dateTime }}</div>
          </div>
          <div class="user-up" @click="dialogVisible = true;">修改密码</div>
        </div>
      </div>

      <div class="item-box msg">
        <div class="statistics-tips">
          <el-badge :value="msgNum" :max="99" v-if="msgNum != 0">
            <span class="title">消息通知</span>
          </el-badge>
          <span class="title" v-if="msgNum == 0">消息通知</span>
        </div>
        <div class="msg-box" v-infinite-scroll="getMessageList"
          :infinite-scroll-disabled="this.msgLoad || this.msgNomore">
          <div class="msg-item" :class="item.is_read == 1 ? '' : 'opacity'" v-for="(item, idx) in msgList" :key="idx">
            <div class="item-header flex ac">
              <div class="dot" v-if="item.is_read == 1"></div>
              <div class="title">{{ item.title }}</div>
            </div>
            <div class="item-desc">【{{ item.project_name }}-{{ item.project_number }}】{{ item.content }}</div>
            <div class="item-btn">
              <div class="time">{{ item.updated_at }}</div>
              <el-button type="text" @click="msgBtn({ item, idx })">查看</el-button>
            </div>
          </div>
          <el-empty v-if="msgList.length == 0" image="https://img01.yzcdn.cn/vant/empty-image-default.png"
            description=" "></el-empty>
        </div>
      </div>
    </div> -->

    <!-- 增减项详情 -->
    <el-drawer title="增减项详情" :visible.sync="zjxDrawerVisible" direction="rtl" size="600px">
      <idiInfo :change_id="checked_id" v-if="zjxDrawerVisible">
      </idiInfo>
    </el-drawer>
    <!-- 售后详情 -->
    <el-drawer title="售后详情" :visible.sync="shDrawerVisible" direction="rtl" size="600px">
      <asInfo :after_sales_id="after_sales_id" v-if="shDrawerVisible">
      </asInfo>
    </el-drawer>
    <!-- 修改密码 -->
    <el-dialog title="修改密码" :visible.sync="dialogVisible" width="400px" destroy-on-close :close-on-click-modal="false">
      <el-form :rules="rules" ref="ruleForm" :model="form" label-position="left">
        <el-form-item label="旧密码" prop="OldPsw">
          <input type="password" style="position: absolute;left: -99999px;opacity: 0;" />
          <el-input type="password" v-model="form.OldPsw" show-password placeholder="请输入旧密码"></el-input>
        </el-form-item>
        <el-form-item label="新密码" prop="NewPsw">
          <input type="password" style="position: absolute;left: -99999px;opacity: 0;" />
          <el-input type="password" v-model="form.NewPsw" show-password placeholder="请输入新密码"></el-input>
        </el-form-item>
        <el-form-item label="确认密码" prop="NewPsw2">
          <input type="password" style="position: absolute;left: -99999px;opacity: 0;" />
          <el-input type="password" v-model="form.NewPsw2" show-password placeholder="请输入确认密码"
            @keyup.enter.native="submitForm('ruleForm')"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm('ruleForm')" :loading="form.submitLoad">确认修改</el-button>
        <el-button @click="dialogVisible = false">取消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { getUserInfo } from '@/utils/auth';
import { handleSpeedDesc } from './kj.js'
import sApi from "@/api/statisticsApi";
import aApi from "@/api/adminApi";
import idiInfo from '@/components/increaseDecreaseItemsInfo';
import asInfo from '@/components/afterSales';
import projectApi from '@/api/projectApi';

export default {
  name: '',
  components: {
    idiInfo,
    asInfo
  },
  data() {
    var NewPsw2 = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('请再次输入新密码'));
      } else if (value != this.form.NewPsw) {
        return callback(new Error('两次密码不一致'));
      } else {
        callback();
      }
    };
    var OldPsw = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('旧密码不能为空'));
      } else {
        callback();
      }
    };
    var NewPsw = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('新密码不能为空'));
      } else if (
        !/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/.test(
          value
        )
      ) {
        callback(new Error('密码须8-16位,包含大小写字母、数字'))
      } else {
        callback();
      }
    };
    return {
      activeName: '1',
      userInfo: {},
      dateTime: '',

      tableData: [],
      tableLoading: false,
      // 消息
      msgPage: 1,
      msgNum: 0,
      msgList: [],
      msgLoad: false,
      msgNomore: false,

      // 侧边栏弹窗
      zjxDrawerVisible: false,
      checked_id: '',
      shDrawerVisible: false,
      after_sales_id: '',

      // 修改密码
      dialogVisible: false,
      rules: {
        OldPsw: { validator: OldPsw, trigger: 'change' },
        NewPsw2: { validator: NewPsw2, trigger: 'change' },
        NewPsw: { validator: NewPsw, trigger: 'change' },
      },
      form: {
        OldPsw: '',
        NewPsw: '',
        NewPsw2: '',
        submitLoad: false
      },

      // 定时请求
      time: 60,
      timer: null,
    }
  },
  computed: {
    speedDesc() {
      return (type, item) => {
        if (type == 3) {
          item.after_sales_status = item.object_status
        } else if (type == 2) {
          item.change_status = item.object_status
        }
        return handleSpeedDesc(type, item, this.userInfo);
      }
    }
  },
  mounted() {
    this.userInfo = getUserInfo();
    this.dateTime = this.formatDate(new Date());


    // this.getMessageList();
    this.getOperList();
  },
  beforeDestroy() {
    if (this.timer) {
      clearInterval(this.timer)
    }
  },
  methods: {
    // 定时刷新
    setIntervalFunc() {
      console.log('开启')
      this.timer = setInterval(() => {
        this.time -= 1;
        if (this.time <= 0) {
          clearInterval(this.timer)
          this.time = 60;
          // this.msgPage = 1;
          // this.msgList = [];
          // this.getMessageList();
          if (this.activeName == '1') {
            this.getOperList();
          } else {
            this.getProjectLogNew();
          }
        }
      }, 1000);
    },
    // 已办列表
    getProjectLogNew() {
      projectApi.getProjectLogNew({
        handlers_id: this.userInfo.userid
      }).then(res => {

        console.log(res, "已办列表")
        if (res.code == 200) {
          res.data.forEach(item => {
            // item.form_data = JSON.parse(item.form_data);
            item.customer_name = item.name;
            item.current_node = item.content;
            item.type = 1;
          });
          this.tableData = res.data || [];
        }
      })
    },
    // 待办/已办
    handleClick(e) {
      if (this.timer) {
        this.time = 60;
        clearInterval(this.timer)
      }
      switch (this.activeName) {
        case '1':
          this.getOperList();
          break;
        case '2':
          this.getProjectLogNew();
          break;
        default:
      }
    },
    // 获取当前时间
    formatDate(date) {
      const year = date.getFullYear();
      const month = (date.getMonth() + 1).toString().padStart(2, '0');
      const day = date.getDate().toString().padStart(2, '0');
      const hours = date.getHours().toString().padStart(2, '0');
      const minutes = date.getMinutes().toString().padStart(2, '0');
      const seconds = date.getSeconds().toString().padStart(2, '0');

      const days = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
      const dayNumber = new Date().getDay();

      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds} ${days[dayNumber]}`;
    },
    // 消息点击查看
    msgBtn(data) {
      console.log(data)
      // 修改未读为已读
      if (data.item.is_read == 1) {
        sApi.readMessage({
          message_id_arr: [data.item.id]
        }).then(res => {
          if (res.code == 200) {
            this.msgNum -= 1;
            this.msgList[data.idx].is_read = 2;
            this.$msgJump(data.item.mark, data.item)
          }
        })
      } else {
        this.$msgJump(data.item.mark, data.item)
      }
    },
    handleEdit(item) {
      this.clickOper(item);
    },
    // 待办列表跳转
    clickOper(item) {
      console.log(item, '点击i', item.object_status)
      if (!item.object_status) {
        console.log('历史')
        this.$router.push({ path: '/projectDetailNew', query: { id: item.project_id } });
        return;
      }
      switch (item.type) {
        case 1:
          // 项目
          this.dbProject(item);
          // this.$router.push({ path: '/projectManagement', query: { project_name: item.project_name } });
          break;
        case 2:
          // 增减项
          this.dbZjx(item);
          // this.$router.push({ path: '/afterSalesManagement', query: { project_name: item.project_name } });
          // console.log(item.type, item.id)
          // this.checked_id = item.id;
          // this.zjxDrawerVisible = true;
          break;
        case 3:
          // 售后
          this.dbAfter(item);
          // this.$router.push({ path: '/increaseDecreaseItemsList', query: { project_name: item.project_name } });
          // this.after_sales_id = item.id;
          // this.shDrawerVisible = true;
          break;
        case 4:
          // 优惠审批
          this.dbDiscountApproval(item);
          break;
        case 5:
          // 施工
          this.dbConstruction(item);
          break;
        case 6:
          // 收款单
          this.dbDjFunc(item);
          break;[]
        case 7:
          // 付款单
          this.dbPayOrderFunc(item);
          break;
        case 8:
          // 整改单
          this.dbzgOrderFunc(item);
          break;
        default:
      }
    },
    // 收款单
    dbDjFunc(item) {
      console.log(item.object_status)
      this.$store.commit('isEventTriggeredFunc', true);
      // 财务审核跳详情
      if (item.status == 10 || item.status == 20 || item.status == 30) {
        this.$router.push({ path: '/collectionPaymentSkdetailPage', query: { id: item.object_id, payment_type: item.object_status, examine: true } });
      } else if (item.status == 15 || item.status == 25 || item.status == 35) {
        this.$router.push({ path: '/collectionPaymentManagement', query: { project_name: item.project_name, payment_type: item.object_status, to_do: '1' } });
      } else {
        // 审核通过
      }
      // if (item.object_status == 1) {
      //   this.$router.push({ path: '/collectionPaymentSkdetailPage', query: { id: item.object_id, payment_type: item.object_status, examine: true } });
      // } else if (item.object_status == 2) {
      //   this.$router.push({ path: '/collectionPaymentSkdetailPage', query: { id: item.object_id, payment_type: item.object_status, examine: true } });
      // } else if (item.object_status == 3) {
      //   this.$router.push({ path: '/collectionPaymentSkdetailPage', query: { id: item.object_id, payment_type: item.object_status, examine: true } });
      // } else if (item.object_status == 4) {
      //   this.$router.push({ path: '/collectionPaymentSkdetailPage', query: { id: item.object_id, payment_type: item.object_status, examine: true } });
      // } else if (item.object_status == 5) {
      //   this.$router.push({ path: '/collectionPaymentSkdetailPage', query: { id: item.object_id, payment_type: item.object_status, examine: true } });
      // } else if (item.object_status == 6) {
      //   this.$router.push({ path: '/collectionPaymentSkdetailPage', query: { id: item.object_id, payment_type: item.object_status, examine: true } });
      // } else {
      //   this.$router.push({ path: '/collectionPaymentManagement', query: { project_name: item.project_name, payment_type: item.object_status, to_do: '1' } });
      // }
      // switch (Number(item.status)) {
      //   case 1230:
      //     this.$router.push({ path: '/collectionPaymentManagement', query: { project_name: item.project_name } });
      //     break;
      //   default:
      // }
    },
    // 代办列表项目display_status
    dbProject(item) {
      let userInfo = getUserInfo();
      console.log(item.status, "项目", userInfo.position_id)
      this.$store.commit('isEventTriggeredFunc', true);
      switch (Number(item.status)) {
        case 1000:
          this.$router.push({ path: '/projectManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1010:
          this.$router.push({ path: '/projectManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1015:
          this.$router.push({ path: '/designManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1020:
          // , to_do: '1'
          // this.$router.push({ path: '/collectionPaymentManagement', query: { project_name: item.project_name } });//跳首付款
          this.$router.push({ path: '/projectManagement', query: { project_name: item.project_name, to_do: '2' } });
          break;
        case 1025:
          this.$router.push({ path: '/collectionPaymentManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1030:
          this.$router.push({ path: '/siteSurveyManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1045:
          this.$router.push({ path: '/siteSurveyManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1055:
          this.$router.push({ path: '/siteSurveyManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1060:
          this.$router.push({ path: '/designManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1065:
          this.$router.push({ path: '/projectManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1070://分配造价员、分配工程经理
          if (userInfo.position_id == 4) {
            // 造价主管
            this.$router.push({ path: '/budgetManagement', query: { project_name: item.project_name, to_do: '1' } });
          } else {
            // 工程部经理
            this.$router.push({ path: '/constructionManagement', query: { project_name: item.project_name, to_do: '1' } });
          }
          break;
        case 1080:// 出具造价单、分配工程经理
          if (userInfo.position_id == 5) {
            // 造价员
            this.$router.push({ path: '/budgetManagement', query: { project_name: item.project_name, to_do: '1' } });
          } else {
            // 工程部经理
            this.$router.push({ path: '/constructionManagement', query: { project_name: item.project_name, to_do: '1' } });
          }
          break;
        case 1090:
          if (userInfo.position_id == 6) {
            // 工程部经理
            this.$router.push({ path: '/constructionManagement', query: { project_name: item.project_name, to_do: '1' } });
          } else {
            // 工程经理审核报价单跳详情
            this.$router.push({ path: '/budgetDetailPage', query: { id: item.project_id, examine: true } });
          }
          break;
        case 1092:
          // 造价主管审核报价单跳详情
          this.$router.push({ path: '/budgetDetailPage', query: { id: item.project_id, examine: true } });
          break;
        case 1095:
          this.$router.push({ path: '/projectManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1100:
          this.$router.push({ path: '/contractManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1102:
          this.$router.push({ path: '/contractManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1105:
          // , to_do: '1'
          // this.$router.push({ path: '/collectionPaymentManagement', query: { project_name: item.project_name, to_do: '1' } });//跳首付款
          this.$router.push({ path: '/projectManagement', query: { project_name: item.project_name, to_do: '2' } });
          break;
        case 1110:
          this.$router.push({ path: '/collectionPaymentManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1115:
          this.$router.push({ path: '/constructionManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1120:
          this.$router.push({ path: '/collectionPaymentManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1125:
          this.$router.push({ path: '/projectManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1130:
          this.$router.push({ path: '/settlementManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1135:
          // this.$router.push({ path: '/settlementManagement', query: { project_name: item.project_name, to_do: '1' } });
          this.$router.push({ path: '/settlemenDetailPage', query: { id: item.object_id, examine: true } });
          break;
        case 1138:
          // this.$router.push({ path: '/settlementManagement', query: { project_name: item.project_name, to_do: '1' } });
          this.$router.push({ path: '/settlemenDetailPage', query: { id: item.object_id, examine: true } });
          break;
          break;
        case 1140:
          // , to_do: '1'
          // this.$router.push({ path: '/collectionPaymentManagement', query: { project_name: item.project_name } });
          this.$router.push({ path: '/projectManagement', query: { project_name: item.project_name, to_do: '2' } });
          break;
        case 1145:
          this.$router.push({ path: '/collectionPaymentManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1150:
          this.$router.push({ path: '/projectManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 1155:
          this.$router.push({ path: '/projectRating', query: { project_name: item.project_name, to_do: '1' } });
          break;
        default:
      }
    },
    // 代办增减项change_status
    dbZjx(item) {
      let userInfo = getUserInfo();
      // 造价主管 --分配造价员
      // if (userInfo.position_id == 4) {
      //   this.$store.commit('isEventTriggeredFunc', true);
      //   this.$router.push({ path: '/increaseDecreaseItemsList', query: { project_name: item.project_name, to_do: '1' } });
      //   return;
      // }
      console.log(item.object_status, "item.object_status")
      this.$store.commit('isEventTriggeredFunc', true);
      switch (item.object_status) {
        case 10:
          this.$router.push({ path: '/increaseDecreaseItemsList', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 20:
          // this.$router.push({ path: '/increaseDecreaseItemsList', query: { project_name: item.project_name, to_do: '1' } });
          this.$router.push({ path: '/increaseDecreaseItemsInfo', query: { sn: item.object_id, examine: true, change_status: item.change_status } });
          break;
        case 25:
          this.$router.push({ path: '/increaseDecreaseItemsList', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 30:
          // this.$router.push({ path: '/increaseDecreaseItemsList', query: { project_name: item.project_name, to_do: '1' } });
          this.$router.push({ path: '/increaseDecreaseItemsInfo', query: { sn: item.object_id, examine: true, change_status: item.change_status } });
          break;
        case 35:
          this.$router.push({ path: '/increaseDecreaseItemsList', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 40:
          // query: { project_name: item.project_name, to_do: '1' } 
          // this.$router.push({ path: '/collectionPaymentManagement', });
          this.$router.push({ path: '/increaseDecreaseItemsInfo', query: { sn: item.object_id, examine: true, change_status: item.change_status } });
          break;
        case 45:
          this.$router.push({ path: '/increaseDecreaseItemsList', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 60:
          this.$router.push({ path: '/increaseDecreaseItemsList', query: { project_name: item.project_name, to_do: '1' } });
          break;
        default:
      }
    },
    // 代办售后after_sales_status
    dbAfter(item) {
      this.$store.commit('isEventTriggeredFunc', true);
      switch (item.object_status) {
        case 10:
          this.$router.push({ path: '/afterSalesManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 20:
          this.$router.push({ path: '/afterSalesManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 30:
          this.$router.push({ path: '/afterSalesManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 40:
          this.$router.push({ path: '/afterSalesManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 50:
          this.$router.push({ path: '/afterSalesManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 60:
          this.$router.push({ path: '/afterSalesManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        default:
      }
    },
    // 代办优惠审批review_status
    dbDiscountApproval(item) {
      // 审核都往详情跳
      this.$store.commit('isEventTriggeredFunc', true);
      switch (item.object_status) {
        case 10:
          this.$router.push({ path: '/discountDetail', query: { id: item.object_id, examine: true } });
          break;
        case 20:
          this.$router.push({ path: '/discountDetail', query: { id: item.object_id, examine: true } });
          break;
        default:
      }
    },
    // 代办施工项目construction_status 
    dbConstruction(item) {
      this.$store.commit('isEventTriggeredFunc', true);
      switch (item.object_status) {
        case 30:
          this.$router.push({ path: '/constructionManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 35:
          this.$router.push({ path: '/constructionManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 40:
          this.$router.push({ path: '/constructionManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 42:
          this.$router.push({ path: '/constructionManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 45:
          // 待提交进度凭证（客户经理）
          if (this.userInfo.position_id == 2) {
            this.$router.push({ path: '/collectionPaymentManagement', query: { project_name: item.project_name } });
            return;
          }
          this.$router.push({ path: '/qualityAcceptance', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 50:
          this.$router.push({ path: '/constructionManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 60:
          this.$router.push({ path: '/constructionManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        case 70:
          this.$router.push({ path: '/constructionManagement', query: { project_name: item.project_name, to_do: '1' } });
          break;
        default:
      }
    },
    // 代办付款单
    dbPayOrderFunc(item) {
      this.$store.commit('isEventTriggeredFunc', true);
      if (item.object_status == 1) {
        this.$router.push({ path: '/collectionPaymentFkdetailPage', query: { id: item.object_id, examine: true } });
        return;
      }
      if (item.object_status == 3) {
        this.$router.push({ path: '/collectionPaymentFkdetailPage', query: { id: item.object_id, examine: true } });
        return;
      }
      if (item.object_status == 4) {
        this.$router.push({ path: '/collectionPaymentFkdetailPage', query: { id: item.object_id, examine: true } });
        return;
      }
      if (item.object_status == 5) {
        this.$router.push({ path: '/collectionPaymentFkdetailPage', query: { id: item.object_id, examine: true } });
        return;
      }
      this.$router.push({ path: '/collectionPaymentManagement', query: { project_name: item.project_name, activeName: '2', to_do: '1' } });
    },
    // 整改单
    dbzgOrderFunc(item) {
      this.$store.commit('isEventTriggeredFunc', true);
      switch (item.object_status) {
        case 3000:
          // this.$router.push({ path: '/rectificationForm', query: { project_name: item.project_name, to_do: '1' } });
          this.$router.push({ path: '/rectificationFormDetailPage', query: { id: item.object_id, submit: true } });
          break;
        case 3002:
          // this.$router.push({ path: '/rectificationForm', query: { project_name: item.project_name, to_do: '1' } });
          this.$router.push({ path: '/rectificationFormDetailPage', query: { id: item.object_id, submit: true } });
          break;
        case 3005:
          // this.$router.push({ path: '/rectificationForm', query: { project_name: item.project_name, to_do: '1' } });
          this.$router.push({ path: '/rectificationFormDetailPage', query: { id: item.object_id, examine: true } });
          break;
        case 3010:
          this.$router.push({ path: '/rectificationForm', query: { project_name: item.project_name, to_do: '1' } });
          break;
        default:
      }
    },

    goPath(path) {
      this.$store.commit('isEventTriggeredFunc', true);
      this.$router.push({ path });
    },
    // 获取操作列表
    getOperList() {
      this.setIntervalFunc();
      this.tableLoading = true;
      sApi.pendingOperationList({
        page: 1,
        num: 999
      }).then(res => {
        console.log(res, '操作列表')
        if (res.code == 200) {
          this.tableData = res.data || [];
        }
        this.tableLoading = false;
      })
    },
    // 获取消息列表
    getMessageList() {
      console.log(this.msgLoad + ' ------- ' + this.msgNomore, "是否被禁止的两个值，有一个是true就不加载")
      this.msgLoad = true;
      sApi.getMessageList({
        page: this.msgPage,
        num: 10,
      }).then(res => {
        console.log(res, '获取消息')
        this.msgLoad = false;
        if (res.code == 200) {
          this.time = 60;
          let msgList = this.msgList;
          this.msgNum = res.data.unread_message_number;
          msgList = [...msgList, ...res.data.list];
          this.msgList = msgList;
          this.msgPage = this.msgPage + 1;
          if (msgList.length == res.data.max) {
            this.msgNomore = true;
          }
        }
      })
    },

    // 修改密码确认
    submitForm(ruleForm) {
      this.$refs[ruleForm].validate((valid) => {
        if (valid) {
          this.updateAdminPassword({
            old_password: this.form.OldPsw,
            new_password: this.form.NewPsw,
          });
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    updateAdminPassword(obj) {
      this.form.submitLoad = true;
      aApi.updPassword({
        new_password: obj.new_password,
        old_password: obj.old_password
      }).then(res => {
        console.log(res, "修改密码")
        this.submitLoad = false;
        if (res.code == 200) {
          setTimeout(() => {
            this.logout();
          }, 1000);
        }
        this.$message({
          type: res.code == 200 ? "success" : "warning",
          message: res.code == 200 ? "修改成功,请重新登录~" : res.message,
        });
      }).catch(err => {
        this.form.submitLoad = false;
      })
    },
    async logout() {
      await this.$store.dispatch('user/logout')
      this.$router.replace(`/login?redirect=${this.$route.fullPath}`)
    },
  }
}
</script>

<style lang="scss" scoped>
@import './index.scss';

.statistics-box {
  height: 100%;
  display: flex;

  .box-left {
    width: 100%; //calc(100% - 415px)
    display: flex;
    flex-direction: column;
  }

  .box-right {
    width: 400px;
    margin-left: 15px;
    display: flex;
    flex-direction: column;
  }
}

// 快捷
.kj-box {
  padding-bottom: 10px;
  width: 100%;


  .kj-item {
    display: inline-block;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: background-color .3s;


    &:hover {
      background-color: #F5F7FA;

      .kj-title {
        color: #202020;
      }
    }

    &:nth-child(5n+1) {
      .kj-icon {
        background: linear-gradient(135deg, #63A8FF 0%, #2C71F7 100%);
      }
    }

    &:nth-child(5n+2) {
      .kj-icon {
        background: linear-gradient(135deg, #78E2C4 0%, #3DAD91 100%);
      }
    }

    &:nth-child(5n+3) {
      .kj-icon {
        background: linear-gradient(135deg, #FBD44A 0%, #F9AD14 100%);
      }
    }

    &:nth-child(5n+4) {
      .kj-icon {
        background: linear-gradient(135deg, #FEA666 0%, #F1631A 100%);
      }
    }

    &:nth-child(5n) {
      .kj-icon {
        background: linear-gradient(135deg, #A3AEFF 0%, #5F79FD 100%);
      }
    }

    .kj-icon {
      width: 40px;
      height: 40px;
      border-radius: 8px;
      line-height: 40px;
      text-align: center;
      margin: 0 auto;

      .iconfont {
        font-size: 22px;
        color: #fff;
        margin-top: 10px;
      }
    }

    .kj-title {
      width: 60px;
      text-align: center;
      margin-top: 10px;
      font-size: 12px;
      color: #828A9D;
    }
  }
}

// 用户信息
.item-box {
  position: relative;
  overflow: hidden;

  .info-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    pointer-events: none;
  }

  .flex {
    position: relative;
    align-items: center;
    height: 100%;
    z-index: 1;

    .user-header {
      width: 75px;
      height: 75px;
      border: 2px solid #fff;
      border-radius: 50%;
      overflow: hidden;

      .user-img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        user-select: none;
        pointer-events: none;
      }
    }

    .user-info {
      flex: 1;
      margin-left: 20px;
      color: #fff;

      .user-name {
        font-size: 16px;
        font-weight: 600;
      }

      .user-desc {
        margin-top: 10px;
        font-size: 12px;
      }
    }

    .user-up {
      width: 70px;
      height: 30px;
      user-select: none;
      cursor: pointer;
      font-size: 12px;
      line-height: 30px;
      text-align: center;
      color: #fff;
      background-color: #143AAE;
      border-radius: 4px;

      &:hover {
        background-color: #1846d1;
      }
    }
  }

}

// 消息通知
.msg {
  width: 400px;
  flex: 1;
  padding-right: 10px;
}

.msg-box {
  height: calc(100% - 40px);
  overflow: auto;
  padding-right: 10px;

  .msg-item+.msg-item {
    margin-top: 10px;
  }

  .opacity {
    opacity: 0.5;
  }

  .msg-item {
    padding: 15px;
    background: #F5F7F7;
    border-radius: 8px;

    .item-header {
      justify-content: space-between;

      .dot {
        width: 5px;
        height: 5px;
        border-radius: 5px;
        margin-right: 8px;
        background: #3B75FF;
      }

      .title {
        flex: 1;
        font-size: 13px;
        font-weight: 600;
        color: #454545;
      }
    }

    .item-desc {
      font-size: 12px;
      color: #5E6276;
      margin-top: 10px;
    }

    .item-btn {
      margin-top: 10px;
      display: flex;
      align-items: center;
      justify-content: space-between;

      .time {
        font-size: 12px;
        color: #9DA0AF;
      }

      ::v-deep .el-button--text {
        padding: 0;
      }
    }
  }
}

::v-deep .el-badge__content {
  line-height: 16px;
}

::v-deep .el-dialog__body {
  padding: 0 20px;
}

.statistics-tips {
  position: relative;
  margin: 0 0 10px 0;

  ::v-deep .el-tabs__nav-wrap::after {
    display: none;
  }


  ::v-deep .el-tabs__header {
    margin: 0;
  }

  ::v-deep .el-tabs__nav-wrap {
    &::after {
      display: none;
    }
  }

  ::v-deep .el-tabs__item {
    font-weight: 400;
    font-size: 16px;
    color: #828a9d;
    padding: 0 !important;
    margin-right: 40px;
    transition: all 0.2s;
  }

  ::v-deep .is-active {
    font-weight: 500;
    font-size: 16px;
    color: #3b75ff;
    position: relative;

    &::after {
      content: "";
      position: absolute;
      width: 27px;
      height: 3px;
      background: #3b75ff;
      border-radius: 1px;
      bottom: 0;
      left: 50%;
      transform: translate(-50%, 0);
    }
  }

  ::v-deep .el-tabs__active-bar {
    background: #3b75ff;
    display: none;
  }

  .dot {
    border-radius: 10px;
    color: #FFF;
    display: inline-block;
    font-size: 12px;
    height: 18px;
    line-height: 16px;
    padding: 0 6px;
    text-align: center;
    white-space: nowrap;
    border: 1px solid #FFF;
    background-color: #F56C6C;
  }

  .dot-xm {
    position: absolute;
    top: -9px;
    right: 112px;
  }

  .dot-zjx {
    position: absolute;
    top: -9px;
    right: 46px;
  }

  .dot-sh {
    position: absolute;
    top: -9px;
    right: -9px;
  }
}

::v-deep .el-table .el-table__empty-block {
  width: 100% !important;
}
</style>